**************************************************************************************************
*** This do file creates the replication results for 
*** The limits to equivalent living conditions: regional disparities in premature mortality in Germany 						 	*/
*** Thomas Pluemper (Department of Socioeconomics, Vienna University of Economics and Business)																		*/
*** Denise Laroze (Centre for Experimental Social Sciences, Universidad de Santiago de Chile)
*** Eric Neumayer (LSE)																			*/
*** 																							*/
*** Published in: Journal of Public Health, 26 (3), 2018, pp. 309-319														*/
**************************************************************************************************
**************************************************************************************************
/* Note: 
You have to change "local DIR" to the directory you copy the original stata files contained 	*/
/* in the zip file and then run the do file. 													*/
**************************************************************************************************

version 14.0
drop _all
clear matrix
clear mata
set mem 800m
set mat 5000

capture net install outreg2, from(http://fmwww.bc.edu/RePEc/bocode/o)			/* checks whether outreg2 is installed 		*/

***********************************************************************************
local DIR = "D:\Research\Health for all database\Germany\"  /*change relative path to the directory where the files are located */
cd "`DIR'"
***********************************************************************************

use "Article for Journal of Public Health (mortality).dta", clear



********************************************
*** Main Regession Models Years Lost and PM
********************************************

su yl pm_74

reg yl schulabganger_ohne_abschluss schulabganger_mit_hochschulreife schulabganger_mit_hauptschulabsc /*
        */ quote_beschaftigte_ohne_berufsab quote_beschaftigte_mit_akademisc /*    
        */ erwerbsquote_frauen erwerbsquote_manner  anteil_auslandische_beschaftigte/*
        */ quote_teilzeitbeschaftigte/*    
		*/ erwerbstatige_primarer_sektor erwerbstatige_sekundarer_sektor /*
        */ Quote_Beschaftigte_an_Experte Quote_Beschaftigte_an_Spezialist  Quote_Beschaftigte_an_Fachkraft Quote_Beschaftigte_an_Helfer/* 
        */ haushaltseinkommen medianeinkommen  durchschnittlicher_rentenzahlbet/*
        */ arbeitslosenquote  arbeitslosenquote_frauen/*        
        */ sgbii_leistungen_je_einwohner alg_ii_leistungen_je_einwohner,
outreg2 using table2, noaster replace excel
		
predict res_yl,  resid     

reg pm_74 schulabganger_ohne_abschluss schulabganger_mit_hochschulreife schulabganger_mit_hauptschulabsc /*
        */ quote_beschaftigte_ohne_berufsab quote_beschaftigte_mit_akademisc /*    
        */ erwerbsquote_frauen erwerbsquote_manner  anteil_auslandische_beschaftigte/*
        */ quote_teilzeitbeschaftigte/*    
		*/ erwerbstatige_primarer_sektor erwerbstatige_sekundarer_sektor /*
        */ Quote_Beschaftigte_an_Experte Quote_Beschaftigte_an_Spezialist  Quote_Beschaftigte_an_Fachkraft Quote_Beschaftigte_an_Helfer/* 
        */ haushaltseinkommen medianeinkommen  durchschnittlicher_rentenzahlbet/*
        */ arbeitslosenquote  arbeitslosenquote_frauen/*        
        */ sgbii_leistungen_je_einwohner alg_ii_leistungen_je_einwohner,

predict res_pm,  resid
outreg2 using table2, noaster append excel




*****************************
*** Latitude 
*****************************

reg yl latitude  
outreg2 using table1a, noaster replace excel nocons
        
reg res_yl latitude  
outreg2 using table1a, noaster append excel nocons

reg pm_74 latitude  
outreg2 using table1a, noaster append excel nocons

reg res_pm latitude  
outreg2 using table1a, noaster append excel nocons

**********************************
*** East-West
***********************************


*** Berlin is defined as East
capture drop east_d
gen east_d =.
replace east_d = 0 if east_west=="West"
replace east_d = 1 if east_west=="East"

reg yl east_d
outreg2 using table1b, noaster replace excel nocons
        
reg res_yl east_d
outreg2 using table1b, noaster append excel nocons

reg pm_74 east_d
outreg2 using table1b, noaster append excel nocons

reg res_pm east_d
outreg2 using table1b, noaster append excel nocons

 

*****************************
*** Contiguity clustering
*****************************

reg yl yl_splag_cont_rwst
outreg2 using table1c, noaster replace excel nocons
        
reg res_yl yl_splag_cont_rwst
outreg2 using table1c, noaster append excel nocons

reg pm_74 pm74_splag_cont_rwst
outreg2 using table1c, noaster append excel nocons

reg res_pm pm74_splag_cont_rwst
outreg2 using table1c, noaster append excel nocons



*****************************
*** Proximity clustering
*****************************

reg yl yl_splag_prox_rwst
outreg2 using table1d, noaster replace excel nocons
        
reg res_yl yl_splag_prox_rwst
outreg2 using table1d, noaster append excel nocons

reg pm_74 pm74_splag_prox_rwst
outreg2 using table1d, noaster append excel nocons

reg res_pm pm74_splag_prox_rwst
outreg2 using table1d, noaster append excel nocons


******************
*** Urbanity
******************

** Use population density

reg yl einwohnerdichte
outreg2 using table1e, noaster replace excel nocons
        
reg res_yl einwohnerdichte
outreg2 using table1e, noaster append excel nocons

reg pm_74 einwohnerdichte
outreg2 using table1e, noaster append excel nocons

reg res_pm einwohnerdichte
outreg2 using table1e, noaster append excel nocons




/**********************************
*** East-West
***********************************


*** Berlin is defined as East
gen east_d = .
replace east_d = 0 if east_west=="West"
replace east_d = 1 if east_west=="East"

reg yl east_d
        
reg pm_74 east_d

reg res_yl east_d

reg res_pm east_d
 

*** Robustness tests on Where Berlin is located. 
gen east_b = east_d
replace east_b = 0 if mcode==11000 // code for Berlin, changing it to West

reg yl east_b
        
reg pm_74 east_b

reg res_yl east_b

reg res_pm east_b

*** Berlin as Missing
replace east_b = . if mcode==11000 // code for Berlin, changing it to missing


reg yl east_b
        
reg pm_74 east_b

reg res_yl east_b

reg res_pm east_b

*/

